﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace VSAero_ProcessingOutput
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string directoryPath;
        System.IO.FileInfo fInfo;
        private void btnInsert_Click(object sender, EventArgs e)
        {

            openFileDialog1.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;
            int size = -1;
            openFileDialog1.Multiselect = true;
            DialogResult results = openFileDialog1.ShowDialog();
            if (results == DialogResult.OK)
            {
                tbResult.Text = openFileDialog1.FileName;
                fInfo = new System.IO.FileInfo(openFileDialog1.FileName);
                directoryPath = fInfo.FullName;
                try
                {
                    string text = File.ReadAllText(tbResult.Text);
                    size = text.Length;
                    richTextBox1.Text = "Size: " + size + "\n";
                    richTextBox1.Text = richTextBox1.Text + text;
                }
                catch (IOException)
                {
                }
            }   
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            StreamReader reader = File.OpenText(directoryPath);
            int counter = 0;
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                if (line.StartsWith(" COLUMN"))
                {
                    line = reader.ReadLine();
                    line = reader.ReadLine();
                    while (!(string.IsNullOrWhiteSpace(line)))
                    {
                        line = reader.ReadToEnd();
                        richTextBox2.Text += line;
                        counter++;

                    }
                    break;
                }
            }
            reader.Close();
        }
    }
}
